<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>输入年份查属相</title>
	</head>
	<body>
		<script>
		var year=prompt("请您输入一个年份");
		var shuYear=1900;
		var diff=year-shuYear;
		if(diff==0 ||diff%12==0){
			alert("鼠");	
		}
		else if(diff==1||diff%12==1 || diff%12==-11){
			alert("牛");
		}
		else if (diff==2 || diff%12==2 ||diff%12==-10){
			alert("虎");
		}
		else if (diff==3 || diff%12==3 || diff%12==-9){
			alert("兔");
		}
		else if( diff==4 || diff%12==4 || diff%12==-8){
			alert("龙");
		}
		else if( diff==5 || diff%12==5 ||diff%12==-7){
			alert("蛇");
		}
		else if (diff==6 || diff%12==6 ||diff%12==-6){
		 	alert("马");
		}
		else if (diff==7 || diff%12==7 ||diff%12==-5){
		 	alert("羊");
		}
		else if (diff==8 || diff%12==8 ||diff%12==-4){
		 	alert("猴");
		}
		else if (diff==9 || diff%12==9 ||diff%12==-3){
		 	alert("鸡");
		}
		else if (diff==10 || diff%12==10 ||diff%12==-2){
		 	alert("狗");
		}
		else if (diff==11 || diff%12==11 ||diff%12==1){
		 	alert("猪");
		}
		else {
			alert("您输入的年份不对！ ");
		}
		</script>
	</body>
</html>
